package xyz.xtt.asset.vo;

import java.util.List;
import java.util.Objects;

import com.google.common.collect.Lists;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import xyz.xtt.asset.client.request.SendHttpResponse;
import xyz.xtt.asset.constants.AssetConstants;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class SuitSupplement {
	/**
	 * 原本成功的
	 */
	private List<SendHttpResponse> succ;
	/**
	 * 需要补发的
	 */
	private Integer[] fill;

	/**
	 * 0失败1成功2部分成功 -1没有操作过
	 */
	private Integer result;

	public static SuitSupplement buildFirst(Integer[] arr) {
		return SuitSupplement.builder().result(AssetConstants.INIT).succ(Lists.newArrayList()).fill(arr).build();
	}

	public static SuitSupplement buildFail(Integer[] arr) {
		return SuitSupplement.builder().result(AssetConstants.BEFORE_FAIL).succ(Lists.newArrayList()).fill(arr).build();
	}

	public static SuitSupplement buildBeforeOk() {
		return SuitSupplement.builder().result(AssetConstants.ALL_OK).succ(Lists.newArrayList()).fill(new Integer[] {}).build();
	}

	/**
	 * 首次调用
	 * 
	 * @return
	 */
	public boolean isFirst() {
		return Objects.equals(result, AssetConstants.INIT);
	}

	/**
	 * 有调用，上次是失败
	 * 
	 * @return
	 */
	public boolean isFail() {
		return Objects.equals(result, AssetConstants.BEFORE_FAIL);
	}

	/**
	 * 已经全部成功
	 * 
	 * @return
	 */
	public boolean isOk() {
		return Objects.equals(result, AssetConstants.ALL_OK);
	}

	/**
	 * 部分成功
	 * 
	 * @return
	 */
	public boolean isAny() {
		return Objects.equals(result, AssetConstants.ANY_OK);
	}

}
